package com.lucker.ds.model;

/**
 * m_domain
 * @author 
 */
public class MDomain extends BaseValueObject {
    /**
     * 地区名称
     */
    private Integer id;

    private String name;

    /**
     * 父地区ID，如果是省，则父地区为0
     */
    private Integer parent;

    /**
     * 删除标志 0 未删除  1删除
     */
    private Integer isDelete;

    private String customQuerySqlText = null;

    private String orderStr = null;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getParent() {
        return parent;
    }

    public void setParent(Integer parent) {
        this.parent = parent;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public void setCustomQuerySqlText(String customQuerySqlText) {
        this.customQuerySqlText = customQuerySqlText;
    }

    public String getCustomQuerySqlText() {
        return customQuerySqlText;
    }

    public void orderById(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by id asc";
            }else{
                this.orderStr = this.orderStr + ",id asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by id desc";
            }else{
                this.orderStr = this.orderStr + ",id desc";
            }
        }
    }

    public void orderByName(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by name asc";
            }else{
                this.orderStr = this.orderStr + ",name asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by name desc";
            }else{
                this.orderStr = this.orderStr + ",name desc";
            }
        }
    }

    public void orderByParent(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by parent asc";
            }else{
                this.orderStr = this.orderStr + ",parent asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by parent desc";
            }else{
                this.orderStr = this.orderStr + ",parent desc";
            }
        }
    }

    public void orderByIsDelete(boolean isAsc) {
        if(isAsc){
            if(this.orderStr == null){
                this.orderStr = "order by is_delete asc";
            }else{
                this.orderStr = this.orderStr + ",is_delete asc";
            }
        }else{
            if(this.orderStr == null){
                this.orderStr = "order by is_delete desc";
            }else{
                this.orderStr = this.orderStr + ",is_delete desc";
            }
        }
    }
}